/* 
 * File:   VectorToScalarDataset.cpp
 * Author: cjjonker
 * 
 * Created on 4 januari 2013, 16:57
 */

#include "VectorToScalarDataset.h"
#include "Vector.h"
#include <cmath>
#include "Utilities.h"


VectorToScalarDataset::VectorToScalarDataset(double* x, double* y, int dim)
:
d_type(Magnitude)
{
    d_x = x;
    d_y = y;
    d_dim = dim;
}

VectorToScalarDataset::VectorToScalarDataset(double* x, double* y, int dim, Type t)
:
d_type(t)
{
    d_x = x;
    d_y = y;
    d_dim = dim;
}


double VectorToScalarDataset::getData(int idx)
{
    switch (d_type)
    {
        case Magnitude:
            return getVectorData(idx).length();
            break;
            
        case Angle:
            std::cout << "If you are experiencing runtime errors, they are caused by VectorToScalarDataset. Fix Angle!";
            return rad2deg(atan2(d_x[idx], d_y[idx]));
            break;
            
        default:
            d_type = Magnitude;
            return getVectorData(idx).length();
            break;
    }
    
}


